package com.jinke.uang.model;

import com.jinke.uang.BuildConfig;
import com.jinke.uang.common.UserInfo;
import com.jinke.uang.constant.HttpConstant;
import com.jinke.uang.http.ModelUtils;
import com.jinke.uang.http.RetrofitManager;
import com.jinke.uang.interfaces.ICommonModule;
import com.jinke.uang.interfaces.ICommonView;
import com.jinke.uang.http.ParamsFactory;

import java.util.HashMap;
import java.util.Map;

/**
 * 作者：Song Shuyu
 * 时间：2019/4/9 16:23
 * package is com.jinke.uang.mvp
 * 借款相关的网络数据请求
 */
public class BorrowModule implements ICommonModule {

    @Override
    public void getData(ICommonView view , int apiType,String listType, Object... t) {
        Map<String, Object> paramsMap = new HashMap<>();
        switch (apiType) {

            case HttpConstant.PRODUCT_DATA://产品计算利率接口
                paramsMap.put("borrowMoney", String.valueOf(t[0]));
                paramsMap.put("pId", String.valueOf(t[1]));
                ModelUtils.ModelUtils(RetrofitManager.getInstance().getINetService().getCalculateData(UserInfo.getToken(), ParamsFactory
                        .getCommonParams(paramsMap)),view,apiType,listType,t);
                break;

            case HttpConstant.CREATE_ORDER://产品借款提单接口
                paramsMap.clear();
                paramsMap.put("expiryReturned", String.valueOf(t[0]).trim());
                paramsMap.put("pId", String.valueOf(t[1]).trim());
                paramsMap.put("userUuid", UserInfo.getSaveUuid());
                paramsMap.put("addressBookUuid",String.valueOf(t[2]));
                ModelUtils.ModelUtils(RetrofitManager.getInstance().getINetService().createOrder(BuildConfig.channel, UserInfo.getToken(), ParamsFactory
                        .getCommonParams(paramsMap)),view,apiType,listType,t);
                break;

            case HttpConstant.CHECK_ORDER_QUALIFICATIONS://是否可以提单接口
                ModelUtils.ModelUtils(RetrofitManager.getInstance().getINetService().checkOrderQualifications(BuildConfig.channel, UserInfo.getToken(), ParamsFactory
                        .getCommonParams(null)),view,apiType,listType,t);
                break;

            case HttpConstant.AUTH_STATUS://获取认证状态接口
                ModelUtils.ModelUtils(RetrofitManager.getInstance().getINetService().getAuthStatus(UserInfo.getToken(),
                        ParamsFactory.getCommonParams(null)), view, apiType,listType, t);
                break;



                default:
                    break;

        }
    }
}
